package com.chukun.netty.codec.customize;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * long类型装换为byte字节 编码器
 */
public class NettyCustomizeMessageToByteEncoder extends MessageToByteEncoder<Long> {

    @Override
    protected void encode(ChannelHandlerContext ctx, Long msg, ByteBuf out) throws Exception {
        System.out.println("NettyCustomizeMessageToByteEncoder encoder : "+msg);
        out.writeLong(msg);
    }
}
